package com.compomics.cellmotionsimulator.components;

import java.awt.*;
import java.sql.DatabaseMetaData;
import java.util.ArrayList;

/**
 * This class represents a single cell.
 */
public class Cell {
    private String iCellName = null;
    private double iPreviousRecalibratedAngle = 0.0;
    private ArrayList<Double> iFacingAngles = null;
    private ArrayList<Point> iSteps = null;

    public Cell(int aSequenceNumber, int aNumberOfSteps, Point aStartingLocation) {
        this.setCellName("Cell_No_" + aSequenceNumber);
        initializeFacingAngles(aNumberOfSteps);
        initializeSteps(aNumberOfSteps+1);
        addStep(aStartingLocation);
    }

    public String getCellName() {
        return iCellName;
    }

    public void setCellName(String aCellName) {
        this.iCellName = aCellName;
    }

    public ArrayList<Point> getSteps() {
        return iSteps;
    }

    public void setSteps(ArrayList<Point> aSteps) {
        this.iSteps = aSteps;
    }

    public void addStep(Point aStep) {
        iSteps.add(aStep);
    }

    public Point getStep(int i) {
        return iSteps.get(i);
    }

    public double getPreviousRecalibratedAngle() {
        return this.iPreviousRecalibratedAngle;
    }

    public void setPreviousRecalibratedAngle(double aPreviousRecalibratedAngle) {
        this.iPreviousRecalibratedAngle = aPreviousRecalibratedAngle;
    }

    public double getFacingAngle(int i) {
        return iFacingAngles.get(i);
    }

    public ArrayList getFacingAngles() {
        return this.iFacingAngles;
    }

    public void addFacingAngle(double aFacingAngle) {
        if(aFacingAngle > Math.PI*2) {
            aFacingAngle -= 2*Math.PI;
        }
        this.iFacingAngles.add(aFacingAngle);
    }

    private void initializeSteps(int aStepCount) {
        iSteps = new ArrayList<Point>(aStepCount);
    }

    private void initializeFacingAngles(int aNumberOfSteps) {
        this.iFacingAngles = new ArrayList<Double>(aNumberOfSteps);
        iFacingAngles.add(0.0);
        iPreviousRecalibratedAngle = Math.random()*2*Math.PI;
    }
}
